package com.titaniume.activitiweb;

import  java.util.Map;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;

/**
 *@program: activiti7_workflow
 *@description:
 *@author: renfei.huang
 *@create: 2021-11-11 13:31
 */
@SpringBootTest
public class Part7_Getway {

    @Autowired
    private TaskService  taskService;

    @Autowired
    private RuntimeService runtimeService;


    //启动流程实例
    @Test
    public void  initProcessInstance(){
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess_1");
        System.out.println("流程定义的ID: " + processInstance.getProcessDefinitionId());
    }

    @Test
    public  void completeTask(){
        //bajie完成任务
//        Map<String, Object> variables = new HashMap<String, Object>();
//        variables.put("day", "2");
//        taskService.complete("21c0c565-42b8-11ec-aef2-8cec4b5c0c44",variables);
        //然后 shaseng和wukong 都有任务了 现在他们两个完成任务这个流程就结束了
        taskService.complete("a6a9e379-42b8-11ec-b622-8cec4b5c0c44");
        taskService.complete("a6a9e37b-42b8-11ec-b622-8cec4b5c0c44");
        System.out.println("完成任务");
    }
}
